function WebSocketConnection() {
    if ("WebSocket" in window) {
        // open a web socket
        var ws = new WebSocket("ws://192.168.10.30:4237");

        ws.onopen = function () {
            ws.send("Message to send from Media Player HUB");
        };

        ws.onmessage = function (evt) {
            var received_msg = evt.data;
			console.log("Received: " + received_msg);
            switch (received_msg) {
                case "swipe up":
					change_level(-1);
					break;
				case "swipe down":
					change_level(1);
					break;
            }
        };

        ws.onclose = function () {
            alert("Connection is closed...");
        };
    } else {
        alert("WebSocket NOT supported by the web browser!");
    }
}
WebSocketConnection();